package com.hx.dc.service.impl;

import com.hx.dc.entity.SysParam;
import com.hx.dc.service.SysParamService;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by death on 2019/2/13.
 */
@Service("sysParamService")
public class SysParamServiceImpl extends BaseServiceImpl<SysParam> implements SysParamService {
    @Override
    public Map<String, Map<Integer, String>> loadSysParam(SysParam sysParam) {
        //存放所有字段
        Map<String,Map<Integer,String>> sysParamMap = new HashMap<>();
        //用来存放字段对应的值
        Map<Integer,String> fieldMap=null;

        List<SysParam> sysParams = sysParamMapper.selectList(sysParam);

        for (SysParam sp:sysParams){
            if(null==sysParamMap.get(sp.getSysParamField())){
                fieldMap=new HashMap<>();
            }else {
                fieldMap =sysParamMap.get(sp.getSysParamField());
            }
            fieldMap.put(sp.getSysParamValue(),sp.getSysParamText());
            sysParamMap.put(sp.getSysParamField(),fieldMap);
            fieldMap=null;
        }
        return sysParamMap;
    }
}
